<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use Hash;
use Session;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\MimaRequest;

class MimaController extends Controller
{
  // 显示密码项
    public function huan(MimaRequest $request){
        //echo session('id');
         //dd($request->all());
        //dd($request -> pass);
        $data=$request->except(['_token']);
         //dd($data);
        // 判断取得原密码是否与数据库一致
         $user = DB::table('member') -> where('id' ,session('id')) -> first();
         if(Hash::check($data['oldpass'] , $user -> pass ))
         {
            //echo 'ok';
           // dd('ok');
            $pass['pass'] = Hash::make($request -> pass);
            $res = DB::table('member') -> where('id' ,session('id')) -> update($pass);
            if($res)
            {
                return redirect('/log/log/log')->with('success','密码修改成功请重新登录吧!');
                // dd('更改成功');
            }else{
                return back()->with('error','密码修改失败');
                // dd('更改失败');
            }

         }else{
            echo 'no';
         }
       }

    
}

